﻿using System;
using System.Runtime.CompilerServices;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Common;
using Ths.Components.Common;
using Ths.Framework;
using Ths.Components.Dictionary;
using Ths.Components.Dictionary.Entity;
using Ths.Components.Excel;
using Ths.Components;
using Dundas.Charting.WebControl;
using Ths.Components.Common;

public partial class DistressManage_AnalysisNotCompany : Base
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            if (Session["ResponseRemark"].ToString() == "局级")
            {
            List<DbParameter> parameterList = new List<DbParameter>();

            DbParameter theSqlParameter = null;
            DataAccess da = new DataAccess();
            DBBase dbBase = new DBBase();
            string where = " ";
            if (GetRequestStr("starttime") != string.Empty)
            {
                where += "  AND HappenTime >= @starttime";
                theSqlParameter = dbBase.DBFactory.CreateParameter("@starttime", Convert.ToString(GetRequestStr("starttime") + " "));
                parameterList.Add(theSqlParameter);

                this.txtStartTime.Value = GetRequestStr("starttime");
            }
            else
            {
                theSqlParameter = dbBase.DBFactory.CreateParameter("@starttime", Convert.ToString(GetRequestStr("starttime") + ""));
                parameterList.Add(theSqlParameter);

            }


            if (GetRequestStr("endtime") != string.Empty)
            {
                where += "  AND HappenTime <= @endtime";
                theSqlParameter = dbBase.DBFactory.CreateParameter("@endtime", Convert.ToString(GetRequestStr("endtime") + " "));
                parameterList.Add(theSqlParameter);
                this.txtEndTime.Value = GetRequestStr("endtime");
            }
            else
            {
                theSqlParameter = dbBase.DBFactory.CreateParameter("@endtime", Convert.ToString(GetRequestStr("endtime") + ""));
                parameterList.Add(theSqlParameter);
            }


            theSqlParameter = dbBase.DBFactory.CreateParameter("@username", Session["username"].ToString());
            parameterList.Add(theSqlParameter);

            DBBase daBase = new DBBase();
            DataTable dtMonthLicence = daBase.DBFactory.GetDataTable("proc_NotHurtCount", CommandType.StoredProcedure, parameterList.ToArray());
            //string monthLicenceTitle = dtMonthLicence.Rows[2]["name"].ToString();

            switch (GetRequestStr("type"))
            {
                case "0":
                    UCChart1.ChartType = SeriesChartType.Pie;
                    this.drpType.SelectedValue = GetRequestStr("type");
                    break;
                case "1":
                    UCChart1.ChartType = SeriesChartType.Column;
                    this.drpType.SelectedValue = GetRequestStr("type");
                    break;
                case "2":
                    UCChart1.ChartType = SeriesChartType.Line;
                    this.drpType.SelectedValue = GetRequestStr("type");
                    break;
                default:
                    UCChart1.ChartType = SeriesChartType.Pie;
                    break;
            }


            //dtMonthLicence.Rows.RemoveAt(2);
            UCChart1.DtSource = dtMonthLicence;
            UCChart1.ImageName = "02-01";
            UCChart1.Width = 400;
            UCChart1.Height = 300;
            }
            else
            {
                Response.Redirect("AnalysisNotCompanyDetail.aspx?bumenid=" + Session["BuMenID"].ToString());
            }
        }

    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        Response.Redirect("AnalysisNotCompany.aspx?starttime=" + this.txtStartTime.Value + "&type=" + this.drpType.SelectedValue + "&endtime=" + this.txtEndTime.Value);
    }
    protected void drpType_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Redirect("AnalysisNotCompany.aspx?starttime=" + this.txtStartTime.Value + "&type=" + this.drpType.SelectedValue + "&endtime=" + this.txtEndTime.Value);
    }
}
